home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
blankery
/
bserverdir
/
sources
/
clients
/
clock.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-29
|
4KB
|
162 lines
;/*
sc Clock.c DATA=FAR NMINC STRMERGE NOSTKCHK IGNORE=73 IGNORE=94 STRUCTUREEQUIVALENCE NOSTDIO
slink from LIB:c.o Clock.o to //Clients/Clock LIB LIB:sc.lib LIB:amiga.lib /lib/client.lib SC SD NOICONS STRIPDEBUG
delete Clock.o
quit
Clock 1.2 (Client for BServer)
Copyright © 1994 by Stefano Reksten of 3AM - The Three Amigos!!!
All rights reserved.
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <graphics/text.h>
#include <graphics/rastport.h>
#include <time.h>
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <clib/diskfont_protos.h>
#include <clib/icon_protos.h>
#include "/include/client.h"
#include "/include/client_pragmas.h"
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *UtilityBase, *IconBase, *DiskfontBase;
struct DisplayIDInformation *dinfo;
struct TextAttr tattr = { "topaz.font", 8, 0, FPF_DISKFONT };
struct TextFont *newfont;
char clkstring[5] = { ' ','0',':','0','0' };
struct IntuiText itext = { 1, 0, JAM1, 0, 0, NULL, clkstring, NULL };
extern ULONG RangeSeed;
void DrawClock( void )
{
struct Screen *scr;
UWORD swidth, sheight, xcrd, ycrd;
struct Rectangle *rect;
ULONG secs, mics, ticks, drawn = 0;
struct ClockData clock;
UWORD fontheight;
rect = GETTXTOSCANRECT(dinfo);
swidth = RECTANGLEWIDTH(rect);
sheight = RECTANGLEHEIGHT(rect);
if ( scr = OpenScreenTags( NULL,
SA_DisplayID, DISPLAYID( dinfo ),
SA_Width, swidth,
SA_Height, sheight,
SA_Left, (RECTANGLEWIDTH(rect) - swidth)/2,
SA_Top, 0,
SA_Depth, 1,
SA_Overscan, OSCAN_TEXT,
SA_Type, CUSTOMSCREEN,
SA_Quiet, TRUE,
TAG_END ) )
{
register struct ViewPort *vp = &(scr->ViewPort);
register struct RastPort *rp = &(scr->RastPort);
SpritesOff();
SetRGB4( vp, 0, 0, 0, 0 );
SetRGB4( vp, 1, 5, 10, 15 );
fontheight = ( newfont ? newfont->tf_YSize : rp->Font->tf_YSize );
ticks = 200;
while( STILL_BLANKING )
{
WaitTOF();
if ( ticks++ == 200 )
{
ticks = 0;
if ( drawn++ )
{
itext.FrontPen = 0;
PrintIText( rp, &itext, xcrd, ycrd );
}
CurrentTime( &secs, &mics );
Amiga2Date( secs, &clock );
clkstring[0] = ( clock.hour > 10 ? '0' + clock.hour / 10 : ' ' );
clkstring[1] = '0' + clock.hour % 10;
clkstring[3] = '0' + clock.min / 10;
clkstring[4] = '0' + clock.min % 10;
itext.FrontPen = 1;
xcrd = RangeRand( swidth - IntuiTextLength( &itext ));
ycrd = RangeRand( sheight - fontheight );
PrintIText( rp, &itext, xcrd, ycrd );
}
}
CloseScreen( scr );
SpritesOn();
}
else
SendClientMsg( ACTION_FAILED );
}
void __main( char *line )
{
if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 37L ) )
{
if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 37L ) )
{
if ( UtilityBase = OpenLibrary( "utility.library", 37L ) )
{
if ( IconBase = OpenLibrary( "icon.library", 37L ) )
{
struct DiskObject *obj;
if ( obj = GetDiskObject( "Clock" ) )
{
char **tooltypes = obj->do_ToolTypes;
tattr.ta_YSize = ArgInt( tooltypes, "FONTHEIGHT", 8 );
tattr.ta_Name = ArgString( tooltypes, "FONTNAME", "topaz.font" );
if ( DiskfontBase = OpenLibrary( "diskfont.library", 37L ) )
{
if ( newfont = OpenDiskFont( &tattr ) )
{
tattr.ta_Flags = newfont->tf_Flags;
itext.ITextFont = &tattr;
}
if ( dinfo = OpenCommunication() )
{
RangeSeed = time( NULL );
DrawClock();
CloseCommunication( dinfo );
}
if ( newfont )
CloseFont( newfont );
CloseLibrary( DiskfontBase );
}
FreeDiskObject( obj );
}
CloseLibrary( IconBase );
}
CloseLibrary( UtilityBase );
}
CloseLibrary( (struct Library *)GfxBase );
}
CloseLibrary( (struct Library *)IntuitionBase );
}
}